gusucode.com > 耐品图片管理系统 标准版A > 耐品图片管理系统 标准版A/Admin_SpecialAdd.asp

    <!--#include file="Admin_ChkPurview.asp"-->
<%
'===============================================================
' 著作权号:中国国家版权局著作权登记号2004SR07385
' 版权所有:深圳市耐品科技开发有限公司 www.naipin.com
' 联系电话:0755-26611119 81234844 81234845
' 联系手机:13316911914
' 联系邮箱:naipin@naipin.com
'===============================================================

Action=trim(Request.Form("Action"))
TypeID=trim(Request.Form("TypeID"))
if Action="Add" then
	Select Case TypeID
		Case 0
			call AddNewSpecial()
		Case 1
			call AddNewArtSpecial()
		Case Else
			FoundErr=True
			ErrMsg = ErrMsg & "<li>请正确选择专题属性</li>"
	End Select
else
	call main()
end if
if FoundErr=True then
	Behind.WriteErrMsg(ErrMsg)
	set Netout=nothing
end if

sub AddNewArtSpecial()
	SpecialName=Netout.HtmlEncode(trim(request.Form("SpecialName")),True)
	set rs = conn.execute("select Max(ID) From Nt_ArtSpecial")
	MaxID=rs(0)
	if isnull(MaxID) then
		MaxID=0
	end if
	rs.close
	ID=MaxID+1
	set rs=conn.execute("select max(rootid) From Nt_ArtSpecial")
	MaxRootID=rs(0)
	if isnull(MaxRootID) then
		MaxRootID=0
	end if
	rs.close
	RootID=MaxRootID+1
	
	if MaxRootID>0 then
		set trs=conn.execute("select ID From Nt_ArtSpecial where RootID=" & MaxRootID)
		PrevID=trs(0)
		trs.close
	else
		PrevID=0
	end if
	PrevOrderID=0

	sql="Select * From Nt_ArtSpecial Where SpecialName='" & SpecialName & "'"
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	if not(rs.bof and rs.eof) then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>已经存在专题:" & SpecialName & "</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
	rs.close

	sql="Select top 1 * From Nt_ArtSpecial"
	rs.open sql,conn,1,3
    	rs.addnew
	rs("ID")=ID
   	rs("SpecialName")=SpecialName
	rs("RootID")=RootID
	rs("OrderID")=PrevOrderID
	rs("PrevID")=PrevID
	rs("NextID")=0
	rs.update
	rs.Close
    	set rs=Nothing
	
	'更新与本专题同一父专题的上一个专题的“NextID”字段值
	if PrevID>0 then
		conn.execute("Update Nt_ArtSpecial set NextID=" & ID & " where ID=" & PrevID)
	end if
	
    	Set Netout = Nothing
	response.Redirect("Admin_ArtSpecial.asp")
end sub

sub AddNewSpecial()
	SpecialName=Netout.HtmlEncode(trim(request.Form("SpecialName")),True)
	set rs = conn.execute("select Max(ID) From Nt_Special")
	MaxID=rs(0)
	if isnull(MaxID) then
		MaxID=0
	end if
	rs.close
	ID=MaxID+1
	set rs=conn.execute("select max(rootid) From Nt_Special")
	MaxRootID=rs(0)
	if isnull(MaxRootID) then
		MaxRootID=0
	end if
	rs.close
	RootID=MaxRootID+1
	
	if MaxRootID>0 then
		set trs=conn.execute("select ID From Nt_Special where RootID=" & MaxRootID)
		PrevID=trs(0)
		trs.close
	else
		PrevID=0
	end if
	PrevOrderID=0

	sql="Select * From Nt_Special Where SpecialName='" & SpecialName & "'"
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	if not(rs.bof and rs.eof) then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>已经存在专题:" & SpecialName & "</li>"
		rs.close
		set rs=nothing
		exit sub
	end if
	rs.close

	sql="Select top 1 * From Nt_Special"
	rs.open sql,conn,1,3
    	rs.addnew
	rs("ID")=ID
   	rs("SpecialName")=SpecialName
	rs("RootID")=RootID
	rs("OrderID")=PrevOrderID
	rs("PrevID")=PrevID
	rs("NextID")=0
	rs.update
	rs.Close
    	set rs=Nothing
	
	'更新与本专题同一父专题的上一个专题的“NextID”字段值
	if PrevID>0 then
		conn.execute("Update Nt_Special set NextID=" & ID & " where ID=" & PrevID)
	end if
	
    	Set Netout = Nothing
	response.Redirect("Admin_Special.asp?specialtype=2")
end sub

sub main()
%>
<html>
<head>
<title>添加专题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript" type="text/JavaScript">
function check()
{
  if (document.form1.SpecialName.value=="")
  {
    alert("专题名称不能为空!");
	document.form1.SpecialName.focus();
	return false;
  }
}
</script>
<%
Behind.WriteHtmlHead
Title="添 加 专 题"
Link="<a href='Admin_Special.asp?specialtype=2' class='black'>管理专题</a> | <a href='Admin_SpecialOrder.asp' class='black'>专题排序</a>"
Behind.WriteHtmlTop Title,Link
%>
  <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
	<form name="form1" method="post" action="Admin_SpecialAdd.asp" onSubmit="return check()">
	<input type="hidden" name="TypeID" value="0">
    <tr class="title"> 
      <td height="22" colspan="2" align="center" class="tdbg1"><strong>添 加 专 题</strong></td>
    </tr>
    <tr class="tdbg"> 
      <td width="248"><strong>专题名称:</strong></td>
      <td><input name="SpecialName" type="text" size="37" maxlength="20"></td>
    </tr>
    <tr class="tdbg"> 
      <td height="40" colspan="2" align="center"><input name="Action" type="hidden" id="Action" value="Add"> 
        <input name="Add" type="submit" value=" 添 加 " style="cursor:hand;"> &nbsp; 
        <input name="Cancel" type="button" id="Cancel" value=" 取 消 " onClick="window.location.href='Admin_Special.asp'" style="cursor:hand;"> 
      </td>
    </tr>
	</form>
  </table>
<%
Behind.WriteHtmlEnd
end sub
%>